<?php session_start(); $ref = getenv('HTTP_REFERER'); ?>
<?php if(isset($_SESSION['username'])) { session_unset(); session_destroy(); header("Location: ".$ref); } else { header("Location: ".$ref); } ?>